package com.telephone.purchase.controller;


import com.alibaba.fastjson.JSON;
import com.telephone.purchase.entity.User;
import com.telephone.purchase.model.UserInfoModifyRequest;
import com.telephone.purchase.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author fengyingeng
 * @date 2019/9/4 16:29
 * Description:
 */
@RestController
@RequestMapping("/v1")
@CrossOrigin
public class UserController {

    @Autowired
    private UserInfoService userInfoServie;

    @RequestMapping(value = "/flushUserInfo")
    public int flushUserInfo(@RequestBody UserInfoModifyRequest userInfoModifyRequest){
        return userInfoServie.modifyUserInfo(userInfoModifyRequest);
    }

    @RequestMapping(value = "/flushUserPassword")
    public int flushUserPassword(@RequestParam(value = "phoneNumber") String phoneNumber, @RequestParam(value = "newUserPassword") String newUserPassword){
        return userInfoServie.modifyUserPassword(phoneNumber, newUserPassword);
    }

    @RequestMapping(value = "/flushPayPassword")
    public int flushPayPassword(@RequestParam(value = "phoneNumber") String phoneNumber, @RequestParam(value = "newPayPassword") String newPayPassword){
        return userInfoServie.modifyPayPassword(phoneNumber, newPayPassword);
    }

    @RequestMapping(value = "/getUserInfo")
    public User getUserInfo(@RequestParam(value = "phoneNumber") String phoneNumber){
        return userInfoServie.getUserInfo(phoneNumber);
    }
}
